home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / out-of-phase-102-c / OutOfPhase 1.02 Source / OutOfPhase Folder / PlayPrefsDialog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  41.3 KB  |  1,274 lines  |  [TEXT/KAHL]

  1. /* PlayPrefsDialog.c */
  2. /*****************************************************************************/
  3. /*                                                                           */
  4. /*    Out Of Phase:  Digital Music Synthesis on General Purpose Computers    */
  5. /*    Copyright (C) 1994  Thomas R. Lawrence                                 */
  6. /*                                                                           */
  7. /*    This program is free software; you can redistribute it and/or modify   */
  8. /*    it under the terms of the GNU General Public License as published by   */
  9. /*    the Free Software Foundation; either version 2 of the License, or      */
  10. /*    (at your option) any later version.                                    */
  11. /*                                                                           */
  12. /*    This program is distributed in the hope that it will be useful,        */
  13. /*    but WITHOUT ANY WARRANTY; without even the implied warranty of         */
  14. /*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
  15. /*    GNU General Public License for more details.                           */
  16. /*                                                                           */
  17. /*    You should have received a copy of the GNU General Public License      */
  18. /*    along with this program; if not, write to the Free Software            */
  19. /*    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              */
  20. /*                                                                           */
  21. /*    Thomas R. Lawrence can be reached at tomlaw@world.std.com.             */
  22. /*                                                                           */
  23. /*****************************************************************************/
  24.  
  25. #include "MiscInfo.h"
  26. #include "Audit.h"
  27. #include "Debug.h"
  28. #include "Definitions.h"
  29.  
  30. #include "PlayPrefsDialog.h"
  31. #include "Memory.h"
  32. #include "Screen.h"
  33. #include "EventLoop.h"
  34. #include "Menus.h"
  35. #include "Alert.h"
  36. #include "MainWindowStuff.h"
  37. #include "StringList.h"
  38. #include "TrackList.h"
  39. #include "Array.h"
  40. #include "TrackObject.h"
  41. #include "TextEdit.h"
  42. #include "DataMunging.h"
  43. #include "SimpleButton.h"
  44. #include "Numbers.h"
  45. #include "Main.h"
  46. #include "RadioButton.h"
  47. #include "CheckBox.h"
  48. #include "SampleDeviceOutput.h"
  49. #include "DiskFileOutput.h"
  50. #include "PlayAIFFFile.h"
  51.  
  52.  
  53. #define WINXSIZE (465)
  54.  
  55. #define INDENTVALUE (100)
  56.  
  57. #define TRACKLISTX (0)
  58. #define TRACKLISTY (0)
  59. #define TRACKLISTWIDTH (200)
  60. #define TRACKLISTHEIGHT (240)
  61.  
  62. #define SELECTALLBUTTONWIDTH (85)
  63. #define SELECTALLBUTTONHEIGHT (21)
  64. #define SELECTALLBUTTONX (TRACKLISTX + (TRACKLISTWIDTH / 2)\
  65.                     - ((TRACKLISTWIDTH / 2) / 2) - (SELECTALLBUTTONWIDTH / 2))
  66. #define SELECTALLBUTTONY (TRACKLISTY + TRACKLISTHEIGHT + 5)
  67.  
  68. #define SELECTNONEBUTTONWIDTH (SELECTALLBUTTONWIDTH)
  69. #define SELECTNONEBUTTONHEIGHT (SELECTALLBUTTONHEIGHT)
  70. #define SELECTNONEBUTTONX (TRACKLISTX + (TRACKLISTWIDTH / 2)\
  71.                     + ((TRACKLISTWIDTH / 2) / 2) - (SELECTALLBUTTONWIDTH / 2))
  72. #define SELECTNONEBUTTONY (SELECTALLBUTTONY)
  73.  
  74. #define CANCELBUTTONWIDTH (95)
  75. #define CANCELBUTTONHEIGHT (SELECTALLBUTTONHEIGHT)
  76. #define CANCELBUTTONX (((1 * WINXSIZE) / 8) - (CANCELBUTTONWIDTH / 2))
  77. #define CANCELBUTTONY (SELECTALLBUTTONY + SELECTALLBUTTONHEIGHT + 10)
  78.  
  79. #define DONTPLAYBUTTONWIDTH (CANCELBUTTONWIDTH)
  80. #define DONTPLAYBUTTONHEIGHT (SELECTALLBUTTONHEIGHT)
  81. #define DONTPLAYBUTTONX (((3 * WINXSIZE) / 8) - (DONTPLAYBUTTONWIDTH / 2))
  82. #define DONTPLAYBUTTONY (CANCELBUTTONY)
  83.  
  84. #define PLAYAUDIOBUTTONWIDTH (CANCELBUTTONWIDTH)
  85. #define PLAYAUDIOBUTTONHEIGHT (SELECTALLBUTTONHEIGHT)
  86. #define PLAYAUDIOBUTTONX (((5 * WINXSIZE) / 8) - (PLAYAUDIOBUTTONWIDTH / 2))
  87. #define PLAYAUDIOBUTTONY (CANCELBUTTONY)
  88.  
  89. #define PLAYDISKBUTTONWIDTH (CANCELBUTTONWIDTH)
  90. #define PLAYDISKBUTTONHEIGHT (SELECTALLBUTTONHEIGHT)
  91. #define PLAYDISKBUTTONX (((7 * WINXSIZE) / 8) - (PLAYDISKBUTTONWIDTH / 2))
  92. #define PLAYDISKBUTTONY (CANCELBUTTONY)
  93.  
  94. #define SAMPLERATEPROMPTX (TRACKLISTX + TRACKLISTWIDTH + 20)
  95. #define SAMPLERATEPROMPTY (13)
  96.  
  97. #define SAMPLERATEEDITX (SAMPLERATEPROMPTX + INDENTVALUE)
  98. #define SAMPLERATEEDITY (SAMPLERATEPROMPTY - 3)
  99. #define SAMPLERATEEDITWIDTH (130)
  100. #define SAMPLERATEEDITHEIGHT (21)
  101.  
  102. #define ENVELOPERATEPROMPTX (SAMPLERATEPROMPTX)
  103. #define ENVELOPERATEPROMPTY (SAMPLERATEPROMPTY + SAMPLERATEEDITHEIGHT + 3)
  104.  
  105. #define ENVELOPERATEEDITX (ENVELOPERATEPROMPTX + INDENTVALUE)
  106. #define ENVELOPERATEEDITY (ENVELOPERATEPROMPTY - 3)
  107. #define ENVELOPERATEEDITWIDTH (SAMPLERATEEDITWIDTH)
  108. #define ENVELOPERATEEDITHEIGHT (SAMPLERATEEDITHEIGHT)
  109.  
  110. #define BEATSPERMINPROMPTX (SAMPLERATEPROMPTX)
  111. #define BEATSPERMINPROMPTY (ENVELOPERATEPROMPTY + ENVELOPERATEEDITHEIGHT + 3)
  112.  
  113. #define BEATSPERMINEDITX (BEATSPERMINPROMPTX + INDENTVALUE)
  114. #define BEATSPERMINEDITY (BEATSPERMINPROMPTY - 3)
  115. #define BEATSPERMINEDITWIDTH (SAMPLERATEEDITWIDTH)
  116. #define BEATSPERMINEDITHEIGHT (SAMPLERATEEDITHEIGHT)
  117.  
  118. #define VOLUMEPROMPTX (SAMPLERATEPROMPTX)
  119. #define VOLUMEPROMPTY (BEATSPERMINPROMPTY + BEATSPERMINEDITHEIGHT + 3)
  120.  
  121. #define VOLUMEEDITX (VOLUMEPROMPTX + INDENTVALUE)
  122. #define VOLUMEEDITY (VOLUMEPROMPTY - 3)
  123. #define VOLUMEEDITWIDTH (SAMPLERATEEDITWIDTH)
  124. #define VOLUMEEDITHEIGHT (SAMPLERATEEDITHEIGHT)
  125.  
  126. #define SCANNINGGAPPROMPTX (SAMPLERATEPROMPTX)
  127. #define SCANNINGGAPPROMPTY (VOLUMEPROMPTY + VOLUMEEDITHEIGHT + 3)
  128.  
  129. #define SCANNINGGAPEDITX (SCANNINGGAPPROMPTX + INDENTVALUE)
  130. #define SCANNINGGAPEDITY (SCANNINGGAPPROMPTY - 3)
  131. #define SCANNINGGAPEDITWIDTH (SAMPLERATEEDITWIDTH)
  132. #define SCANNINGGAPEDITHEIGHT (SAMPLERATEEDITHEIGHT)
  133.  
  134. #define BUFFERDURATIONPROMPTX (SAMPLERATEPROMPTX)
  135. #define BUFFERDURATIONPROMPTY (SCANNINGGAPPROMPTY + SCANNINGGAPEDITHEIGHT + 3)
  136.  
  137. #define BUFFERDURATIONEDITX (BUFFERDURATIONPROMPTX + INDENTVALUE)
  138. #define BUFFERDURATIONEDITY (BUFFERDURATIONPROMPTY - 3)
  139. #define BUFFERDURATIONWIDTH (SAMPLERATEEDITWIDTH)
  140. #define BUFFERDURATIONHEIGHT (SAMPLERATEEDITHEIGHT)
  141.  
  142. #define BITS8BUTTONX (BUFFERDURATIONPROMPTX)
  143. #define BITS8BUTTONY (BUFFERDURATIONPROMPTY + VOLUMEEDITHEIGHT + 5)
  144. #define BITS8BUTTONWIDTH (100)
  145. #define BITS8BUTTONHEIGHT (SAMPLERATEEDITHEIGHT)
  146.  
  147. #define BITS16BUTTONX (BITS8BUTTONX)
  148. #define BITS16BUTTONY (BITS8BUTTONY + BITS8BUTTONHEIGHT - 1)
  149. #define BITS16BUTTONWIDTH (BITS8BUTTONWIDTH)
  150. #define BITS16BUTTONHEIGHT (BITS8BUTTONHEIGHT)
  151.  
  152. #define BITS24BUTTONX (BITS8BUTTONX)
  153. #define BITS24BUTTONY (BITS16BUTTONY + BITS16BUTTONHEIGHT - 1)
  154. #define BITS24BUTTONWIDTH (BITS8BUTTONWIDTH)
  155. #define BITS24BUTTONHEIGHT (BITS8BUTTONHEIGHT)
  156.  
  157. #define BITS32BUTTONX (BITS8BUTTONX)
  158. #define BITS32BUTTONY (BITS24BUTTONY + BITS24BUTTONHEIGHT - 1)
  159. #define BITS32BUTTONWIDTH (BITS8BUTTONWIDTH)
  160. #define BITS32BUTTONHEIGHT (BITS8BUTTONHEIGHT)
  161.  
  162. #define STEREOBUTTONX (BITS8BUTTONX + 105)
  163. #define STEREOBUTTONY (BITS8BUTTONY)
  164. #define STEREOBUTTONWIDTH (80)
  165. #define STEREOBUTTONHEIGHT (SAMPLERATEEDITHEIGHT)
  166.  
  167. #define MONOBUTTONX (STEREOBUTTONX)
  168. #define MONOBUTTONY (STEREOBUTTONY + STEREOBUTTONHEIGHT - 1)
  169. #define MONOBUTTONWIDTH (STEREOBUTTONWIDTH)
  170. #define MONOBUTTONHEIGHT (SAMPLERATEEDITHEIGHT)
  171.  
  172. #define INTERPTIMEBUTTONX (STEREOBUTTONX)
  173. #define INTERPTIMEBUTTONY (MONOBUTTONY + MONOBUTTONHEIGHT + 5)
  174. #define INTERPTIMEBUTTONWIDTH (140)
  175. #define INTERPTIMEBUTTONHEIGHT (SAMPLERATEEDITHEIGHT)
  176.  
  177. #define INTERPWAVEBUTTONX (STEREOBUTTONX)
  178. #define INTERPWAVEBUTTONY (INTERPTIMEBUTTONY + INTERPTIMEBUTTONHEIGHT - 1)
  179. #define INTERPWAVEBUTTONWIDTH (INTERPTIMEBUTTONWIDTH)
  180. #define INTERPWAVEBUTTONHEIGHT (SAMPLERATEEDITHEIGHT)
  181.  
  182. #define CLIPWARNBUTTONX (STEREOBUTTONX)
  183. #define CLIPWARNBUTTONY (INTERPWAVEBUTTONY + INTERPWAVEBUTTONHEIGHT + 5)
  184. #define CLIPWARNBUTTONWIDTH (INTERPTIMEBUTTONWIDTH)
  185. #define CLIPWARNBUTTONHEIGHT (SAMPLERATEEDITHEIGHT)
  186.  
  187. #define WINYSIZE (CANCELBUTTONY + CANCELBUTTONHEIGHT + 10)
  188.  
  189.  
  190. typedef struct
  191.     {
  192.         WinType*                        ScreenID;
  193.         StringListRec*            TrackActivationList;
  194.         SimpleButtonRec*        SelectAllButton;
  195.         SimpleButtonRec*        SelectNoneButton;
  196.         SimpleButtonRec*        CancelButton;
  197.         SimpleButtonRec*        DontPlayButton;
  198.         SimpleButtonRec*        PlayAudioButton;
  199.         SimpleButtonRec*        PlayDiskButton;
  200.         TextEditRec*                SampleRateEdit;
  201.         TextEditRec*                EnvelopeRateEdit;
  202.         TextEditRec*                BeatsPerMinEdit;
  203.         TextEditRec*                VolumeEdit;
  204.         TextEditRec*                ScanningGapEdit;
  205.         TextEditRec*                DurationWidthEdit;
  206.         RadioButtonRec*            Bits8Button;
  207.         RadioButtonRec*            Bits16Button;
  208.         RadioButtonRec*            Bits24Button;
  209.         RadioButtonRec*            Bits32Button;
  210.         RadioButtonRec*            StereoButton;
  211.         RadioButtonRec*            MonoButton;
  212.         CheckBoxRec*                InterpTimeButton;
  213.         CheckBoxRec*                InterpWaveButton;
  214.         CheckBoxRec*                ClipWarnButton;
  215.     } WindowRec;
  216.  
  217.  
  218. static void                    RedrawTheWindow(WindowRec* Window)
  219.     {
  220.         CheckPtrExistence(Window);
  221.         RedrawStringList(Window->TrackActivationList);
  222.         RedrawSimpleButton(Window->SelectAllButton);
  223.         RedrawSimpleButton(Window->SelectNoneButton);
  224.         RedrawSimpleButton(Window->CancelButton);
  225.         RedrawSimpleButton(Window->DontPlayButton);
  226.         RedrawSimpleButton(Window->PlayAudioButton);
  227.         RedrawSimpleButton(Window->PlayDiskButton);
  228.         TextEditFullRedraw(Window->SampleRateEdit);
  229.         TextEditFullRedraw(Window->EnvelopeRateEdit);
  230.         TextEditFullRedraw(Window->BeatsPerMinEdit);
  231.         TextEditFullRedraw(Window->VolumeEdit);
  232.         TextEditFullRedraw(Window->ScanningGapEdit);
  233.         TextEditFullRedraw(Window->DurationWidthEdit);
  234.         RedrawRadioButton(Window->Bits8Button);
  235.         RedrawRadioButton(Window->Bits16Button);
  236.         RedrawRadioButton(Window->Bits24Button);
  237.         RedrawRadioButton(Window->Bits32Button);
  238.         RedrawRadioButton(Window->StereoButton);
  239.         RedrawRadioButton(Window->MonoButton);
  240.         RedrawCheckBox(Window->InterpTimeButton);
  241.         RedrawCheckBox(Window->InterpWaveButton);
  242.         RedrawCheckBox(Window->ClipWarnButton);
  243.         SetClipRect(Window->ScreenID,0,0,WINXSIZE,WINYSIZE);
  244.         DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Sampling Rate:",14,
  245.             SAMPLERATEPROMPTX,SAMPLERATEPROMPTY,ePlain);
  246.         DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Envelope Rate:",14,
  247.             ENVELOPERATEPROMPTX,ENVELOPERATEPROMPTY,ePlain);
  248.         DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Beats Per Minute:",17,
  249.             BEATSPERMINPROMPTX,BEATSPERMINPROMPTY,ePlain);
  250.         DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Inverse Volume:",15,
  251.             VOLUMEPROMPTX,VOLUMEPROMPTY,ePlain);
  252.         DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Scanning Gap:",13,
  253.             SCANNINGGAPPROMPTX,SCANNINGGAPPROMPTY,ePlain);
  254.         DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Buffer Seconds:",15,
  255.             BUFFERDURATIONPROMPTX,BUFFERDURATIONPROMPTY,ePlain);
  256.     }
  257.  
  258.  
  259. typedef enum
  260.     {
  261.         eCancelled EXECUTE(= -21985),
  262.         eDontPlay,
  263.         ePlayToDevice,
  264.         ePlayToDisk
  265.     } CommandType;
  266.  
  267.  
  268. /* show the play prefs dialog (which also allows the user to play) */
  269. void                                DoPlayPrefsDialog(struct MainWindowRec* MainWindow,
  270.                                             struct TrackListRec* TrackList)
  271.     {
  272.         WindowRec*                Window;
  273.         ArrayRec*                    ArrayTemp;
  274.         long                            Scan;
  275.         long                            Limit;
  276.         MyBoolean                    LoopFlag;
  277.         TextEditRec*            ActiveTextEdit;
  278.         CommandType                Operation EXECUTE(= (CommandType)-31342);
  279.         char*                            StringTemp;
  280.  
  281.         CheckPtrExistence(MainWindow);
  282.  
  283.         Window = (WindowRec*)AllocPtrCanFail(sizeof(WindowRec),"WindowRec");
  284.         if (Window == NIL)
  285.             {
  286.              FailurePoint1:
  287.                 AlertHalt("There is not enough memory available to display the playback "
  288.                     "dialog box.",NIL);
  289.                 return;
  290.             }
  291.  
  292.         Window->ScreenID = MakeNewWindow(eModelessDialogWindow,eWindowNotClosable,
  293.             eWindowNotZoomable,eWindowNotResizable,DialogLeftEdge(WINXSIZE),
  294.             DialogTopEdge(WINYSIZE),WINXSIZE,WINYSIZE,
  295.             (void (*)(void*))&RedrawTheWindow,Window);
  296.         if (Window->ScreenID == NIL)
  297.             {
  298.              FailurePoint2:
  299.                 ReleasePtr((char*)Window);
  300.                 goto FailurePoint1;
  301.             }
  302.         SetWindowName(Window->ScreenID,"Play Parameters");
  303.  
  304.         Window->TrackActivationList = NewStringList(Window->ScreenID,TRACKLISTX,
  305.             TRACKLISTY,TRACKLISTWIDTH,TRACKLISTHEIGHT,GetScreenFont(),9,
  306.             StringListDoAllowMultipleSelection,"Tracks to Play:");
  307.         if (Window->TrackActivationList == NIL)
  308.             {
  309.              FailurePoint3:
  310.                 KillWindow(Window->ScreenID);
  311.                 goto FailurePoint2;
  312.             }
  313.         EnableStringList(Window->TrackActivationList);
  314.         ArrayTemp = TrackListGetListOfAllTracks(TrackList);
  315.         if (ArrayTemp == NIL)
  316.             {
  317.              FailurePoint4:
  318.                 DisposeStringList(Window->TrackActivationList);
  319.                 goto FailurePoint3;
  320.             }
  321.         Limit = ArrayGetLength(ArrayTemp);
  322.         for (Scan = 0; Scan < Limit; Scan += 1)
  323.             {
  324.                 char*                            TrackName;
  325.                 TrackObjectRec*        TheTrackObject;
  326.                 char*                            TrackNameNullTerminated;
  327.  
  328.                 TheTrackObject = (TrackObjectRec*)ArrayGetElement(ArrayTemp,Scan);
  329.                 TrackName = TrackObjectGetNameCopy(TheTrackObject);
  330.                 if (TrackName == NIL)
  331.                     {
  332.                      FailurePoint4a:
  333.                         DisposeArray(ArrayTemp);
  334.                         goto FailurePoint4;
  335.                     }
  336.                 TrackNameNullTerminated = BlockToStringCopy(TrackName);
  337.                 if (TrackNameNullTerminated == NIL)
  338.                     {
  339.                      FailurePoint4b:
  340.                         ReleasePtr(TrackName);
  341.                         goto FailurePoint4a;
  342.                     }
  343.                 if (!InsertStringListElement(Window->TrackActivationList,
  344.                     TrackNameNullTerminated,NIL,TheTrackObject,False))
  345.                     {
  346.                      FailurePoint4c:
  347.                         ReleasePtr(TrackNameNullTerminated);
  348.                         goto FailurePoint4b;
  349.                     }
  350.                 if (TrackObjectShouldItBePlayed(TheTrackObject))
  351.                     {
  352.                         SelectStringListElement(Window->TrackActivationList,TheTrackObject);
  353.                     }
  354.                 ReleasePtr(TrackNameNullTerminated);
  355.                 ReleasePtr(TrackName);
  356.             }
  357.         DisposeArray(ArrayTemp);
  358.  
  359.         Window->SelectAllButton = NewSimpleButton(Window->ScreenID,"Select All",
  360.             SELECTALLBUTTONX,SELECTALLBUTTONY,SELECTALLBUTTONWIDTH,SELECTALLBUTTONHEIGHT);
  361.         if (Window->SelectAllButton == NIL)
  362.             {
  363.              FailurePoint5:
  364.                 goto FailurePoint4;
  365.             }
  366.  
  367.         Window->SelectNoneButton = NewSimpleButton(Window->ScreenID,"Deselect All",
  368.             SELECTNONEBUTTONX,SELECTNONEBUTTONY,SELECTNONEBUTTONWIDTH,SELECTNONEBUTTONHEIGHT);
  369.         if (Window->SelectNoneButton == NIL)
  370.             {
  371.              FailurePoint6:
  372.                 DisposeSimpleButton(Window->SelectAllButton);
  373.                 goto FailurePoint5;
  374.             }
  375.  
  376.         Window->CancelButton = NewSimpleButton(Window->ScreenID,"Cancel",
  377.             CANCELBUTTONX,CANCELBUTTONY,CANCELBUTTONWIDTH,CANCELBUTTONHEIGHT);
  378.         if (Window->CancelButton == NIL)
  379.             {
  380.              FailurePoint7:
  381.                 DisposeSimpleButton(Window->SelectNoneButton);
  382.                 goto FailurePoint6;
  383.             }
  384.  
  385.         Window->DontPlayButton = NewSimpleButton(Window->ScreenID,"Done",
  386.             DONTPLAYBUTTONX,DONTPLAYBUTTONY,DONTPLAYBUTTONWIDTH,DONTPLAYBUTTONHEIGHT);
  387.         if (Window->DontPlayButton == NIL)
  388.             {
  389.              FailurePoint8:
  390.                 DisposeSimpleButton(Window->CancelButton);
  391.                 goto FailurePoint7;
  392.             }
  393.  
  394.         Window->PlayAudioButton = NewSimpleButton(Window->ScreenID,"Play To Audio",
  395.             PLAYAUDIOBUTTONX,PLAYAUDIOBUTTONY,PLAYAUDIOBUTTONWIDTH,PLAYAUDIOBUTTONHEIGHT);
  396.         if (Window->PlayAudioButton == NIL)
  397.             {
  398.              FailurePoint9:
  399.                 DisposeSimpleButton(Window->DontPlayButton);
  400.                 goto FailurePoint8;
  401.             }
  402.  
  403.         Window->PlayDiskButton = NewSimpleButton(Window->ScreenID,"Play To Disk",
  404.             PLAYDISKBUTTONX,PLAYDISKBUTTONY,PLAYDISKBUTTONWIDTH,PLAYDISKBUTTONHEIGHT);
  405.         if (Window->PlayDiskButton == NIL)
  406.             {
  407.              FailurePoint10:
  408.                 DisposeSimpleButton(Window->PlayAudioButton);
  409.                 goto FailurePoint9;
  410.             }
  411.  
  412.         Window->SampleRateEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,
  413.             GetScreenFont(),9,SAMPLERATEEDITX,SAMPLERATEEDITY,SAMPLERATEEDITWIDTH,
  414.             SAMPLERATEEDITHEIGHT);
  415.         if (Window->SampleRateEdit == NIL)
  416.             {
  417.              FailurePoint11:
  418.                 DisposeSimpleButton(Window->PlayDiskButton);
  419.                 goto FailurePoint10;
  420.             }
  421.         StringTemp = IntegerToString(MainWindowGetSamplingRate(MainWindow));
  422.         if (StringTemp == NIL)
  423.             {
  424.              FailurePoint12:
  425.                 DisposeTextEdit(Window->SampleRateEdit);
  426.                 goto FailurePoint11;
  427.             }
  428.         TextEditNewRawData(Window->SampleRateEdit,StringTemp,SYSTEMLINEFEED);
  429.         ReleasePtr(StringTemp);
  430.  
  431.         Window->EnvelopeRateEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,
  432.             GetScreenFont(),9,ENVELOPERATEEDITX,ENVELOPERATEEDITY,ENVELOPERATEEDITWIDTH,
  433.             ENVELOPERATEEDITHEIGHT);
  434.         if (Window->EnvelopeRateEdit == NIL)
  435.             {
  436.              FailurePoint13:
  437.                 goto FailurePoint12;
  438.             }
  439.         StringTemp = IntegerToString(MainWindowGetEnvelopeRate(MainWindow));
  440.         if (StringTemp == NIL)
  441.             {
  442.              FailurePoint14:
  443.                 DisposeTextEdit(Window->EnvelopeRateEdit);
  444.                 goto FailurePoint13;
  445.             }
  446.         TextEditNewRawData(Window->EnvelopeRateEdit,StringTemp,SYSTEMLINEFEED);
  447.         ReleasePtr(StringTemp);
  448.  
  449.         Window->BeatsPerMinEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,
  450.             GetScreenFont(),9,BEATSPERMINEDITX,BEATSPERMINEDITY,BEATSPERMINEDITWIDTH,
  451.             BEATSPERMINEDITHEIGHT);
  452.         if (Window->BeatsPerMinEdit == NIL)
  453.             {
  454.              FailurePoint15:
  455.                 goto FailurePoint14;
  456.             }
  457.         StringTemp = LongDoubleToString(MainWindowGetBeatsPerMinute(MainWindow),7,1e-4,1e6);
  458.         if (StringTemp == NIL)
  459.             {
  460.              FailurePoint16:
  461.                 DisposeTextEdit(Window->BeatsPerMinEdit);
  462.                 goto FailurePoint15;
  463.             }
  464.         TextEditNewRawData(Window->BeatsPerMinEdit,StringTemp,SYSTEMLINEFEED);
  465.         ReleasePtr(StringTemp);
  466.  
  467.         Window->VolumeEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,
  468.             GetScreenFont(),9,VOLUMEEDITX,VOLUMEEDITY,VOLUMEEDITWIDTH,VOLUMEEDITHEIGHT);
  469.         if (Window->VolumeEdit == NIL)
  470.             {
  471.              FailurePoint17:
  472.                 goto FailurePoint16;
  473.             }
  474.         StringTemp = LongDoubleToString(MainWindowGetVolumeScaling(MainWindow),7,1e-4,1e6);
  475.         if (StringTemp == NIL)
  476.             {
  477.              FailurePoint18:
  478.                 DisposeTextEdit(Window->VolumeEdit);
  479.                 goto FailurePoint17;
  480.             }
  481.         TextEditNewRawData(Window->VolumeEdit,StringTemp,SYSTEMLINEFEED);
  482.         ReleasePtr(StringTemp);
  483.  
  484.         Window->Bits8Button = NewRadioButton(Window->ScreenID,"8-Bit Output",
  485.             BITS8BUTTONX,BITS8BUTTONY,BITS8BUTTONWIDTH,BITS8BUTTONHEIGHT);
  486.         if (Window->Bits8Button == NIL)
  487.             {
  488.              FailurePoint19:
  489.                 goto FailurePoint18;
  490.             }
  491.  
  492.         Window->Bits16Button = NewRadioButton(Window->ScreenID,"16-Bit Output",
  493.             BITS16BUTTONX,BITS16BUTTONY,BITS16BUTTONWIDTH,BITS16BUTTONHEIGHT);
  494.         if (Window->Bits16Button == NIL)
  495.             {
  496.              FailurePoint20:
  497.                 DisposeRadioButton(Window->Bits8Button);
  498.                 goto FailurePoint19;
  499.             }
  500.  
  501.         Window->Bits24Button = NewRadioButton(Window->ScreenID,"24-Bit Output",
  502.             BITS24BUTTONX,BITS24BUTTONY,BITS24BUTTONWIDTH,BITS24BUTTONHEIGHT);
  503.         if (Window->Bits24Button == NIL)
  504.             {
  505.              FailurePoint21:
  506.                 DisposeRadioButton(Window->Bits16Button);
  507.                 goto FailurePoint20;
  508.             }
  509.  
  510.         Window->Bits32Button = NewRadioButton(Window->ScreenID,"32-Bit Output",
  511.             BITS32BUTTONX,BITS32BUTTONY,BITS32BUTTONWIDTH,BITS32BUTTONHEIGHT);
  512.         if (Window->Bits32Button == NIL)
  513.             {
  514.              FailurePoint22:
  515.                 DisposeRadioButton(Window->Bits24Button);
  516.                 goto FailurePoint21;
  517.             }
  518.  
  519.         switch (MainWindowGetOutputNumBits(MainWindow))
  520.             {
  521.                 default:
  522.                     EXECUTE(PRERR(ForceAbort,
  523.                         "DoPlayPrefsDialog:  bad num bits value from MainWindow"));
  524.                     break;
  525.                 case eOutput8Bits:
  526.                     SetRadioButtonState(Window->Bits8Button,True);
  527.                     break;
  528.                 case eOutput16Bits:
  529.                     SetRadioButtonState(Window->Bits16Button,True);
  530.                     break;
  531.                 case eOutput24Bits:
  532.                     SetRadioButtonState(Window->Bits24Button,True);
  533.                     break;
  534.                 case eOutput32Bits:
  535.                     SetRadioButtonState(Window->Bits32Button,True);
  536.                     break;
  537.             }
  538.  
  539.         Window->StereoButton = NewRadioButton(Window->ScreenID,"Stereo",
  540.             STEREOBUTTONX,STEREOBUTTONY,STEREOBUTTONWIDTH,STEREOBUTTONHEIGHT);
  541.         if (Window->StereoButton == NIL)
  542.             {
  543.              FailurePoint23:
  544.                 DisposeRadioButton(Window->Bits32Button);
  545.                 goto FailurePoint22;
  546.             }
  547.  
  548.         Window->MonoButton = NewRadioButton(Window->ScreenID,"Mono",
  549.             MONOBUTTONX,MONOBUTTONY,MONOBUTTONWIDTH,MONOBUTTONHEIGHT);
  550.         if (Window->MonoButton == NIL)
  551.             {
  552.              FailurePoint24:
  553.                 DisposeRadioButton(Window->StereoButton);
  554.                 goto FailurePoint23;
  555.             }
  556.  
  557.         if (MainWindowGetStereo(MainWindow))
  558.             {
  559.                 SetRadioButtonState(Window->StereoButton,True);
  560.             }
  561.          else
  562.             {
  563.                 SetRadioButtonState(Window->MonoButton,True);
  564.             }
  565.  
  566.         Window->InterpTimeButton = NewCheckBox(Window->ScreenID,"Interpolate Over Time",
  567.             INTERPTIMEBUTTONX,INTERPTIMEBUTTONY,INTERPTIMEBUTTONWIDTH,INTERPTIMEBUTTONHEIGHT);
  568.         if (Window->InterpTimeButton == NIL)
  569.             {
  570.              FailurePoint25:
  571.                 DisposeRadioButton(Window->MonoButton);
  572.                 goto FailurePoint24;
  573.             }
  574.         SetCheckBoxState(Window->InterpTimeButton,
  575.             MainWindowGetInterpolationOverTime(MainWindow));
  576.  
  577.         Window->InterpWaveButton = NewCheckBox(Window->ScreenID,"Interpolate Across Waves",
  578.             INTERPWAVEBUTTONX,INTERPWAVEBUTTONY,INTERPWAVEBUTTONWIDTH,INTERPWAVEBUTTONHEIGHT);
  579.         if (Window->InterpWaveButton == NIL)
  580.             {
  581.              FailurePoint26:
  582.                 DisposeCheckBox(Window->InterpTimeButton);
  583.                 goto FailurePoint25;
  584.             }
  585.         SetCheckBoxState(Window->InterpWaveButton,
  586.             MainWindowGetInterpolationAcrossWaves(MainWindow));
  587.  
  588.         Window->ScanningGapEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,
  589.             GetScreenFont(),9,SCANNINGGAPEDITX,SCANNINGGAPEDITY,SCANNINGGAPEDITWIDTH,
  590.             SCANNINGGAPEDITHEIGHT);
  591.         if (Window->ScanningGapEdit == NIL)
  592.             {
  593.              FailurePoint27:
  594.                 DisposeCheckBox(Window->InterpWaveButton);
  595.                 goto FailurePoint26;
  596.             }
  597.         StringTemp = LongDoubleToString(MainWindowGetScanningGap(MainWindow),7,1e-4,1e6);
  598.         if (StringTemp == NIL)
  599.             {
  600.              FailurePoint28:
  601.                 DisposeTextEdit(Window->ScanningGapEdit);
  602.                 goto FailurePoint27;
  603.             }
  604.         TextEditNewRawData(Window->ScanningGapEdit,StringTemp,SYSTEMLINEFEED);
  605.         ReleasePtr(StringTemp);
  606.  
  607.         Window->DurationWidthEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,
  608.             GetScreenFont(),9,BUFFERDURATIONEDITX,BUFFERDURATIONEDITY,BUFFERDURATIONWIDTH,
  609.             BUFFERDURATIONHEIGHT);
  610.         if (Window->DurationWidthEdit == NIL)
  611.             {
  612.              FailurePoint29:
  613.                 goto FailurePoint28;
  614.             }
  615.         StringTemp = LongDoubleToString(MainWindowGetBufferDuration(MainWindow),5,1e-4,1e6);
  616.         if (StringTemp == NIL)
  617.             {
  618.              FailurePoint30:
  619.                 DisposeTextEdit(Window->DurationWidthEdit);
  620.                 goto FailurePoint29;
  621.             }
  622.         TextEditNewRawData(Window->DurationWidthEdit,StringTemp,SYSTEMLINEFEED);
  623.         ReleasePtr(StringTemp);
  624.  
  625.         Window->ClipWarnButton = NewCheckBox(Window->ScreenID,"Clip Warning",CLIPWARNBUTTONX,
  626.             CLIPWARNBUTTONY,CLIPWARNBUTTONWIDTH,CLIPWARNBUTTONHEIGHT);
  627.         if (Window->ClipWarnButton == NIL)
  628.             {
  629.              FailurePoint31:
  630.                 goto FailurePoint30;
  631.             }
  632.         SetCheckBoxState(Window->ClipWarnButton,MainWindowGetClipWarning(MainWindow));
  633.  
  634.  
  635.         ActiveTextEdit = Window->SampleRateEdit;
  636.         EnableTextEditSelection(ActiveTextEdit);
  637.         TextEditDoMenuSelectAll(ActiveTextEdit);
  638.      JumpBackIntoLoopPoint:
  639.         LoopFlag = True;
  640.         while (LoopFlag)
  641.             {
  642.                 OrdType                            X;
  643.                 OrdType                            Y;
  644.                 ModifierFlags                Modifiers;
  645.                 MenuItemType*                MenuItem;
  646.                 char                                KeyPress;
  647.  
  648.                 switch (GetAnEvent(&X,&Y,&Modifiers,NIL,&MenuItem,&KeyPress))
  649.                     {
  650.                         default:
  651.                             break;
  652.                         case eCheckCursor:
  653.                             if (TextEditIBeamTest(Window->SampleRateEdit,X,Y)
  654.                                 || TextEditIBeamTest(Window->EnvelopeRateEdit,X,Y)
  655.                                 || TextEditIBeamTest(Window->BeatsPerMinEdit,X,Y)
  656.                                 || TextEditIBeamTest(Window->VolumeEdit,X,Y)
  657.                                 || TextEditIBeamTest(Window->ScanningGapEdit,X,Y)
  658.                                 || TextEditIBeamTest(Window->DurationWidthEdit,X,Y))
  659.                                 {
  660.                                     SetIBeamCursor();
  661.                                 }
  662.                              else
  663.                                 {
  664.                                     SetArrowCursor();
  665.                                 }
  666.                             goto UpdateCursorPoint;
  667.                             break;
  668.                         case eNoEvent:
  669.                          UpdateCursorPoint:
  670.                             TextEditUpdateCursor(ActiveTextEdit);
  671.                             break;
  672.                         case eMenuStarting:
  673.                             EnableMenuItem(mPaste);
  674.                             if (TextEditIsThereValidSelection(ActiveTextEdit))
  675.                                 {
  676.                                     EnableMenuItem(mCut);
  677.                                     EnableMenuItem(mCopy);
  678.                                     EnableMenuItem(mClear);
  679.                                 }
  680.                             EnableMenuItem(mSelectAll);
  681.                             if (TextEditCanWeUndo(ActiveTextEdit))
  682.                                 {
  683.                                     EnableMenuItem(mUndo);
  684.                                 }
  685.                             EnableMenuItem(mPlayAIFFFile);
  686.                             break;
  687.                         case eMenuCommand:
  688.                             if (MenuItem == mPaste)
  689.                                 {
  690.                                     TextEditDoMenuPaste(ActiveTextEdit);
  691.                                 }
  692.                             else if (MenuItem == mCut)
  693.                                 {
  694.                                     TextEditDoMenuCut(ActiveTextEdit);
  695.                                 }
  696.                             else if (MenuItem == mCopy)
  697.                                 {
  698.                                     TextEditDoMenuCopy(ActiveTextEdit);
  699.                                 }
  700.                             else if (MenuItem == mClear)
  701.                                 {
  702.                                     TextEditDoMenuClear(ActiveTextEdit);
  703.                                 }
  704.                             else if (MenuItem == mUndo)
  705.                                 {
  706.                                     TextEditDoMenuUndo(ActiveTextEdit);
  707.                                     TextEditShowSelection(ActiveTextEdit);
  708.                                 }
  709.                             else if (MenuItem == mSelectAll)
  710.                                 {
  711.                                     TextEditDoMenuSelectAll(ActiveTextEdit);
  712.                                 }
  713.                             else if (MenuItem == mPlayAIFFFile)
  714.                                 {
  715.                                     PlayAIFFFile();
  716.                                 }
  717.                             else
  718.                                 {
  719.                                     EXECUTE(PRERR(AllowResume,
  720.                                         "DoPlayPrefsDialog: Undefined menu option chosen"));
  721.                                 }
  722.                             break;
  723.                         case eKeyPressed:
  724.                             if (KeyPress == 13)
  725.                                 {
  726.                                     /* no default button */
  727.                                 }
  728.                             else if (KeyPress == 9)
  729.                                 {
  730.                                     DisableTextEditSelection(ActiveTextEdit);
  731.                                     if ((eShiftKey & Modifiers) == 0)
  732.                                         {
  733.                                             /* tab forwards */
  734.                                             if (ActiveTextEdit == Window->SampleRateEdit)
  735.                                                 {
  736.                                                     ActiveTextEdit = Window->EnvelopeRateEdit;
  737.                                                 }
  738.                                             else if (ActiveTextEdit == Window->EnvelopeRateEdit)
  739.                                                 {
  740.                                                     ActiveTextEdit = Window->BeatsPerMinEdit;
  741.                                                 }
  742.                                             else if (ActiveTextEdit == Window->BeatsPerMinEdit)
  743.                                                 {
  744.                                                     ActiveTextEdit = Window->VolumeEdit;
  745.                                                 }
  746.                                             else if (ActiveTextEdit == Window->VolumeEdit)
  747.                                                 {
  748.                                                     ActiveTextEdit = Window->ScanningGapEdit;
  749.                                                 }
  750.                                             else if (ActiveTextEdit == Window->ScanningGapEdit)
  751.                                                 {
  752.                                                     ActiveTextEdit = Window->DurationWidthEdit;
  753.                                                 }
  754.                                             else
  755.                                                 {
  756.                                                     ActiveTextEdit = Window->SampleRateEdit;
  757.                                                 }
  758.                                         }
  759.                                      else
  760.                                         {
  761.                                             /* tab backwards */
  762.                                             if (ActiveTextEdit == Window->DurationWidthEdit)
  763.                                                 {
  764.                                                     ActiveTextEdit = Window->ScanningGapEdit;
  765.                                                 }
  766.                                             if (ActiveTextEdit == Window->ScanningGapEdit)
  767.                                                 {
  768.                                                     ActiveTextEdit = Window->VolumeEdit;
  769.                                                 }
  770.                                             else if (ActiveTextEdit == Window->VolumeEdit)
  771.                                                 {
  772.                                                     ActiveTextEdit = Window->BeatsPerMinEdit;
  773.                                                 }
  774.                                             else if (ActiveTextEdit == Window->BeatsPerMinEdit)
  775.                                                 {
  776.                                                     ActiveTextEdit = Window->EnvelopeRateEdit;
  777.                                                 }
  778.                                             else if (ActiveTextEdit == Window->EnvelopeRateEdit)
  779.                                                 {
  780.                                                     ActiveTextEdit = Window->SampleRateEdit;
  781.                                                 }
  782.                                             else
  783.                                                 {
  784.                                                     ActiveTextEdit = Window->DurationWidthEdit;
  785.                                                 }
  786.                                         }
  787.                                     TextEditDoMenuSelectAll(ActiveTextEdit);
  788.                                     EnableTextEditSelection(ActiveTextEdit);
  789.                                 }
  790.                             else if (KeyPress == eCancelKey)
  791.                                 {
  792.                                     /* FlashButton(Window->CancelButton); */
  793.                                     /* Operation = eCancelled; */
  794.                                     /* LoopFlag = False; */
  795.                                 }
  796.                             else
  797.                                 {
  798.                                     TextEditDoKeyPressed(ActiveTextEdit,KeyPress,Modifiers);
  799.                                 }
  800.                             break;
  801.                         case eMouseDown:
  802.                             if (SimpleButtonHitTest(Window->CancelButton,X,Y))
  803.                                 {
  804.                                     if (SimpleButtonMouseDown(Window->CancelButton,X,Y,NIL,NIL))
  805.                                         {
  806.                                             Operation = eCancelled;
  807.                                             LoopFlag = False;
  808.                                         }
  809.                                 }
  810.                             else if (SimpleButtonHitTest(Window->DontPlayButton,X,Y))
  811.                                 {
  812.                                     if (SimpleButtonMouseDown(Window->DontPlayButton,X,Y,NIL,NIL))
  813.                                         {
  814.                                             Operation = eDontPlay;
  815.                                             LoopFlag = False;
  816.                                         }
  817.                                 }
  818.                             else if (SimpleButtonHitTest(Window->PlayAudioButton,X,Y))
  819.                                 {
  820.                                     if (SimpleButtonMouseDown(Window->PlayAudioButton,X,Y,NIL,NIL))
  821.                                         {
  822.                                             Operation = ePlayToDevice;
  823.                                             LoopFlag = False;
  824.                                         }
  825.                                 }
  826.                             else if (SimpleButtonHitTest(Window->PlayDiskButton,X,Y))
  827.                                 {
  828.                                     if (SimpleButtonMouseDown(Window->PlayDiskButton,X,Y,NIL,NIL))
  829.                                         {
  830.                                             Operation = ePlayToDisk;
  831.                                             LoopFlag = False;
  832.                                         }
  833.                                 }
  834.                             else if (TextEditHitTest(Window->SampleRateEdit,X,Y))
  835.                                 {
  836.                                     if (ActiveTextEdit != Window->SampleRateEdit)
  837.                                         {
  838.                                             DisableTextEditSelection(ActiveTextEdit);
  839.                                             ActiveTextEdit = Window->SampleRateEdit;
  840.                                             EnableTextEditSelection(ActiveTextEdit);
  841.                                         }
  842.                                     TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
  843.                                 }
  844.                             else if (TextEditHitTest(Window->EnvelopeRateEdit,X,Y))
  845.                                 {
  846.                                     if (ActiveTextEdit != Window->EnvelopeRateEdit)
  847.                                         {
  848.                                             DisableTextEditSelection(ActiveTextEdit);
  849.                                             ActiveTextEdit = Window->EnvelopeRateEdit;
  850.                                             EnableTextEditSelection(ActiveTextEdit);
  851.                                         }
  852.                                     TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
  853.                                 }
  854.                             else if (TextEditHitTest(Window->BeatsPerMinEdit,X,Y))
  855.                                 {
  856.                                     if (ActiveTextEdit != Window->BeatsPerMinEdit)
  857.                                         {
  858.                                             DisableTextEditSelection(ActiveTextEdit);
  859.                                             ActiveTextEdit = Window->BeatsPerMinEdit;
  860.                                             EnableTextEditSelection(ActiveTextEdit);
  861.                                         }
  862.                                     TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
  863.                                 }
  864.                             else if (TextEditHitTest(Window->VolumeEdit,X,Y))
  865.                                 {
  866.                                     if (ActiveTextEdit != Window->VolumeEdit)
  867.                                         {
  868.                                             DisableTextEditSelection(ActiveTextEdit);
  869.                                             ActiveTextEdit = Window->VolumeEdit;
  870.                                             EnableTextEditSelection(ActiveTextEdit);
  871.                                         }
  872.                                     TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
  873.                                 }
  874.                             else if (TextEditHitTest(Window->ScanningGapEdit,X,Y))
  875.                                 {
  876.                                     if (ActiveTextEdit != Window->ScanningGapEdit)
  877.                                         {
  878.                                             DisableTextEditSelection(ActiveTextEdit);
  879.                                             ActiveTextEdit = Window->ScanningGapEdit;
  880.                                             EnableTextEditSelection(ActiveTextEdit);
  881.                                         }
  882.                                     TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
  883.                                 }
  884.                             else if (TextEditHitTest(Window->DurationWidthEdit,X,Y))
  885.                                 {
  886.                                     if (ActiveTextEdit != Window->DurationWidthEdit)
  887.                                         {
  888.                                             DisableTextEditSelection(ActiveTextEdit);
  889.                                             ActiveTextEdit = Window->DurationWidthEdit;
  890.                                             EnableTextEditSelection(ActiveTextEdit);
  891.                                         }
  892.                                     TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
  893.                                 }
  894.                             else if (StringListHitTest(Window->TrackActivationList,X,Y))
  895.                                 {
  896.                                     /* double-click means nothing */
  897.                                     StringListMouseDown(Window->TrackActivationList,X,Y,Modifiers);
  898.                                 }
  899.                             else if (SimpleButtonHitTest(Window->SelectAllButton,X,Y))
  900.                                 {
  901.                                     if (SimpleButtonMouseDown(Window->SelectAllButton,X,Y,NIL,NIL))
  902.                                         {
  903.                                             ArrayTemp = TrackListGetListOfAllTracks(TrackList);
  904.                                             if (ArrayTemp != NIL)
  905.                                                 {
  906.                                                     Limit = ArrayGetLength(ArrayTemp);
  907.                                                     for (Scan = 0; Scan < Limit; Scan += 1)
  908.                                                         {
  909.                                                             TrackObjectRec*        TheTrackObject;
  910.  
  911.                                                             TheTrackObject = (TrackObjectRec*)ArrayGetElement(
  912.                                                                 ArrayTemp,Scan);
  913.                                                             SelectStringListElement(Window->TrackActivationList,
  914.                                                                 TheTrackObject);
  915.                                                         }
  916.                                                     DisposeArray(ArrayTemp);
  917.                                                 }
  918.                                         }
  919.                                 }
  920.                             else if (SimpleButtonHitTest(Window->SelectNoneButton,X,Y))
  921.                                 {
  922.                                     if (SimpleButtonMouseDown(Window->SelectNoneButton,X,Y,NIL,NIL))
  923.                                         {
  924.                                             DeselectAllStringListElements(Window->TrackActivationList);
  925.                                         }
  926.                                 }
  927.                             else if (RadioButtonHitTest(Window->Bits8Button,X,Y))
  928.                                 {
  929.                                     if (RadioButtonMouseDown(Window->Bits8Button,X,Y))
  930.                                         {
  931.                                             SetRadioButtonState(Window->Bits16Button,False);
  932.                                             SetRadioButtonState(Window->Bits24Button,False);
  933.                                             SetRadioButtonState(Window->Bits32Button,False);
  934.                                         }
  935.                                 }
  936.                             else if (RadioButtonHitTest(Window->Bits16Button,X,Y))
  937.                                 {
  938.                                     if (RadioButtonMouseDown(Window->Bits16Button,X,Y))
  939.                                         {
  940.                                             SetRadioButtonState(Window->Bits8Button,False);
  941.                                             SetRadioButtonState(Window->Bits24Button,False);
  942.                                             SetRadioButtonState(Window->Bits32Button,False);
  943.                                         }
  944.                                 }
  945.                             else if (RadioButtonHitTest(Window->Bits24Button,X,Y))
  946.                                 {
  947.                                     if (RadioButtonMouseDown(Window->Bits24Button,X,Y))
  948.                                         {
  949.                                             SetRadioButtonState(Window->Bits8Button,False);
  950.                                             SetRadioButtonState(Window->Bits16Button,False);
  951.                                             SetRadioButtonState(Window->Bits32Button,False);
  952.                                         }
  953.                                 }
  954.                             else if (RadioButtonHitTest(Window->Bits32Button,X,Y))
  955.                                 {
  956.                                     if (RadioButtonMouseDown(Window->Bits32Button,X,Y))
  957.                                         {
  958.                                             SetRadioButtonState(Window->Bits8Button,False);
  959.                                             SetRadioButtonState(Window->Bits16Button,False);
  960.                                             SetRadioButtonState(Window->Bits24Button,False);
  961.                                         }
  962.                                 }
  963.                             else if (RadioButtonHitTest(Window->StereoButton,X,Y))
  964.                                 {
  965.                                     if (RadioButtonMouseDown(Window->StereoButton,X,Y))
  966.                                         {
  967.                                             SetRadioButtonState(Window->MonoButton,False);
  968.                                         }
  969.                                 }
  970.                             else if (RadioButtonHitTest(Window->MonoButton,X,Y))
  971.                                 {
  972.                                     if (RadioButtonMouseDown(Window->MonoButton,X,Y))
  973.                                         {
  974.                                             SetRadioButtonState(Window->StereoButton,False);
  975.                                         }
  976.                                 }
  977.                             else if (CheckBoxHitTest(Window->InterpTimeButton,X,Y))
  978.                                 {
  979.                                     CheckBoxMouseDown(Window->InterpTimeButton,X,Y);
  980.                                     if (!GetCheckBoxState(Window->InterpTimeButton))
  981.                                         {
  982.                                             SetCheckBoxState(Window->InterpWaveButton,False);
  983.                                         }
  984.                                 }
  985.                             else if (CheckBoxHitTest(Window->InterpWaveButton,X,Y))
  986.                                 {
  987.                                     CheckBoxMouseDown(Window->InterpWaveButton,X,Y);
  988.                                     if (GetCheckBoxState(Window->InterpWaveButton))
  989.                                         {
  990.                                             SetCheckBoxState(Window->InterpTimeButton,True);
  991.                                         }
  992.                                 }
  993.                             else if (CheckBoxHitTest(Window->ClipWarnButton,X,Y))
  994.                                 {
  995.                                     CheckBoxMouseDown(Window->ClipWarnButton,X,Y);
  996.                                 }
  997.                             break;
  998.                     }
  999.             }
  1000.  
  1001.         {
  1002.             long                            SamplingRate;
  1003.             long                            EnvelopeRate;
  1004.             double                        DefaultBeatsPerMinute;
  1005.             double                        VolumeScaling;
  1006.             OutputNumBitsType    NumberOfBits;
  1007.             MyBoolean                    StereoPlayback;
  1008.             MyBoolean                    TimeInterpolation;
  1009.             MyBoolean                    WaveInterpolation;
  1010.             double                        ScanningGap;
  1011.             double                        DurationWidth;
  1012.             ArrayRec*                    PlayTrackList;
  1013.             MyBoolean                    ClipWarning;
  1014.  
  1015.             char*                            StringTemp;
  1016.             MyBoolean                    MemOutErrorOccurred = False;
  1017.  
  1018.             StringTemp = TextEditGetRawData(Window->SampleRateEdit,SYSTEMLINEFEED);
  1019.             if (StringTemp != NIL)
  1020.                 {
  1021.                     SamplingRate = StringToInteger(StringTemp,PtrSize(StringTemp));
  1022.                     if (SamplingRate < MINSAMPLINGRATE)
  1023.                         {
  1024.                             SamplingRate = MINSAMPLINGRATE;
  1025.                         }
  1026.                     if (SamplingRate > MAXSAMPLINGRATE)
  1027.                         {
  1028.                             SamplingRate = MAXSAMPLINGRATE;
  1029.                         }
  1030.                     ReleasePtr(StringTemp);
  1031.                 }
  1032.              else
  1033.                 {
  1034.                     MemOutErrorOccurred = True;
  1035.                 }
  1036.  
  1037.             StringTemp = TextEditGetRawData(Window->EnvelopeRateEdit,SYSTEMLINEFEED);
  1038.             if (StringTemp != NIL)
  1039.                 {
  1040.                     EnvelopeRate = StringToInteger(StringTemp,PtrSize(StringTemp));
  1041.                     ReleasePtr(StringTemp);
  1042.                     if (EnvelopeRate < 1)
  1043.                         {
  1044.                             EnvelopeRate = 1;
  1045.                         }
  1046.                     if (EnvelopeRate > MAXSAMPLINGRATE)
  1047.                         {
  1048.                             EnvelopeRate = MAXSAMPLINGRATE;
  1049.                         }
  1050.                 }
  1051.              else
  1052.                 {
  1053.                     MemOutErrorOccurred = True;
  1054.                 }
  1055.  
  1056.             StringTemp = TextEditGetRawData(Window->BeatsPerMinEdit,SYSTEMLINEFEED);
  1057.             if (StringTemp != NIL)
  1058.                 {
  1059.                     DefaultBeatsPerMinute = StringToLongDouble(StringTemp,PtrSize(StringTemp));
  1060.                     ReleasePtr(StringTemp);
  1061.                 }
  1062.              else
  1063.                 {
  1064.                     MemOutErrorOccurred = True;
  1065.                 }
  1066.  
  1067.             StringTemp = TextEditGetRawData(Window->VolumeEdit,SYSTEMLINEFEED);
  1068.             if (StringTemp != NIL)
  1069.                 {
  1070.                     VolumeScaling = StringToLongDouble(StringTemp,PtrSize(StringTemp));
  1071.                     ReleasePtr(StringTemp);
  1072.                 }
  1073.              else
  1074.                 {
  1075.                     MemOutErrorOccurred = True;
  1076.                 }
  1077.  
  1078.             StringTemp = TextEditGetRawData(Window->ScanningGapEdit,SYSTEMLINEFEED);
  1079.             if (StringTemp != NIL)
  1080.                 {
  1081.                     ScanningGap = StringToLongDouble(StringTemp,PtrSize(StringTemp));
  1082.                     ReleasePtr(StringTemp);
  1083.                 }
  1084.              else
  1085.                 {
  1086.                     MemOutErrorOccurred = True;
  1087.                 }
  1088.  
  1089.             StringTemp = TextEditGetRawData(Window->DurationWidthEdit,SYSTEMLINEFEED);
  1090.             if (StringTemp != NIL)
  1091.                 {
  1092.                     DurationWidth = StringToLongDouble(StringTemp,PtrSize(StringTemp));
  1093.                     ReleasePtr(StringTemp);
  1094.                 }
  1095.              else
  1096.                 {
  1097.                     MemOutErrorOccurred = True;
  1098.                 }
  1099.  
  1100.             if (GetRadioButtonState(Window->Bits8Button))
  1101.                 {
  1102.                     NumberOfBits = eOutput8Bits;
  1103.                 }
  1104.             else if (GetRadioButtonState(Window->Bits16Button))
  1105.                 {
  1106.                     NumberOfBits = eOutput16Bits;
  1107.                 }
  1108.             else if (GetRadioButtonState(Window->Bits24Button))
  1109.                 {
  1110.                     NumberOfBits = eOutput24Bits;
  1111.                 }
  1112.             else if (GetRadioButtonState(Window->Bits32Button))
  1113.                 {
  1114.                     NumberOfBits = eOutput32Bits;
  1115.                 }
  1116.             else
  1117.                 {
  1118.                     EXECUTE(PRERR(ForceAbort,"DoPlayPrefsDialog:  bits buttons problem"));
  1119.                 }
  1120.  
  1121.             if (GetRadioButtonState(Window->StereoButton))
  1122.                 {
  1123.                     StereoPlayback = True;
  1124.                 }
  1125.             else if (GetRadioButtonState(Window->MonoButton))
  1126.                 {
  1127.                     StereoPlayback = False;
  1128.                 }
  1129.             else
  1130.                 {
  1131.                     EXECUTE(PRERR(ForceAbort,"DoPlayPrefsDialog:  stereo buttons problem"));
  1132.                 }
  1133.  
  1134.             TimeInterpolation = GetCheckBoxState(Window->InterpTimeButton);
  1135.  
  1136.             WaveInterpolation = GetCheckBoxState(Window->InterpWaveButton);
  1137.  
  1138.             ClipWarning = GetCheckBoxState(Window->ClipWarnButton);
  1139.  
  1140.             PlayTrackList = GetListOfSelectedItems(Window->TrackActivationList);
  1141.             if (PlayTrackList == NIL)
  1142.                 {
  1143.                     MemOutErrorOccurred = True;
  1144.                 }
  1145.  
  1146.             if (MemOutErrorOccurred)
  1147.                 {
  1148.                     AlertHalt("There is not enough memory available to continue.",NIL);
  1149.                 }
  1150.              else
  1151.                 {
  1152.                     long                                Scan;
  1153.                     ArrayRec*                        TotalTrackList;
  1154.  
  1155.                     switch (Operation)
  1156.                         {
  1157.                             default:
  1158.                                 EXECUTE(PRERR(ForceAbort,"DoPlayPrefsDialog:  Operation was not set"));
  1159.                                 break;
  1160.                             case eCancelled:
  1161.                                 /* do nothing, including not saving the parameters */
  1162.                                 DisposeArray(PlayTrackList);
  1163.                                 break;
  1164.                             case eDontPlay:
  1165.                                 PutMainWindowSamplingRate(MainWindow,SamplingRate);
  1166.                                 PutMainWindowEnvelopeRate(MainWindow,EnvelopeRate);
  1167.                                 PutMainWindowBeatsPerMinute(MainWindow,DefaultBeatsPerMinute);
  1168.                                 PutMainWindowVolumeScaling(MainWindow,VolumeScaling);
  1169.                                 PutMainWindowOutputNumBits(MainWindow,NumberOfBits);
  1170.                                 PutMainWindowStereo(MainWindow,StereoPlayback);
  1171.                                 PutMainWindowInterpolationOverTime(MainWindow,TimeInterpolation);
  1172.                                 PutMainWindowInterpolationAcrossWaves(MainWindow,WaveInterpolation);
  1173.                                 PutMainWindowScanningGap(MainWindow,ScanningGap);
  1174.                                 PutMainWindowBufferDuration(MainWindow,DurationWidth);
  1175.                                 PutMainWindowClipWarning(MainWindow,ClipWarning);
  1176.                                 /* first, we should save the information in PlayTrackList */
  1177.                                 TotalTrackList = TrackListGetListOfAllTracks(TrackList);
  1178.                                 if (TotalTrackList != NIL)
  1179.                                     {
  1180.                                         for (Scan = 0; Scan < ArrayGetLength(TotalTrackList); Scan += 1)
  1181.                                             {
  1182.                                                 TrackObjectRec*        OneTrack;
  1183.  
  1184.                                                 OneTrack = (TrackObjectRec*)ArrayGetElement(TotalTrackList,Scan);
  1185.                                                 CheckPtrExistence(OneTrack);
  1186.                                                 if (-1 != ArrayFindElement(PlayTrackList,OneTrack))
  1187.                                                     {
  1188.                                                         /* it's marked to be played */
  1189.                                                         if (!TrackObjectShouldItBePlayed(OneTrack))
  1190.                                                             {
  1191.                                                                 /* it has to be changed */
  1192.                                                                 ChangeTrackObjectShouldBePlayed(OneTrack,True);
  1193.                                                             }
  1194.                                                     }
  1195.                                                  else
  1196.                                                     {
  1197.                                                         /* it's marked to not be played */
  1198.                                                         if (TrackObjectShouldItBePlayed(OneTrack))
  1199.                                                             {
  1200.                                                                 /* it has to be changed */
  1201.                                                                 ChangeTrackObjectShouldBePlayed(OneTrack,False);
  1202.                                                             }
  1203.                                                     }
  1204.                                             }
  1205.                                         DisposeArray(TotalTrackList);
  1206.                                     }
  1207.                                 DisposeArray(PlayTrackList);
  1208.                                 break;
  1209.                             case ePlayToDevice:
  1210.                                 /* play to the audio device, but don't save the parameters */
  1211.                                 if (ArrayGetLength(PlayTrackList) == 0)
  1212.                                     {
  1213.                                         AlertHalt("No tracks are selected.",NIL);
  1214.                                     }
  1215.                                  else
  1216.                                     {
  1217.                                         SynthToSoundDevice(MainWindow,PlayTrackList,
  1218.                                             (TrackObjectRec*)ArrayGetElement(PlayTrackList,0),0,SamplingRate,
  1219.                                             EnvelopeRate,StereoPlayback,Double2LargeBCD(DefaultBeatsPerMinute),
  1220.                                             Double2LargeBCD(VolumeScaling),TimeInterpolation,
  1221.                                             WaveInterpolation,Double2LargeBCD(ScanningGap),NumberOfBits,
  1222.                                             Double2LargeBCD(DurationWidth),
  1223.                                             ClipWarning && ((eOptionKey & CheckModifiers()) == 0));
  1224.                                     }
  1225.                                 DisposeArray(PlayTrackList);
  1226.                                 goto JumpBackIntoLoopPoint;
  1227.                             case ePlayToDisk:
  1228.                                 /* play to disk, but don't save the parameters */
  1229.                                 if (ArrayGetLength(PlayTrackList) == 0)
  1230.                                     {
  1231.                                         AlertHalt("No tracks are selected.",NIL);
  1232.                                     }
  1233.                                  else
  1234.                                     {
  1235.                                         SynthToAIFFFile(MainWindow,PlayTrackList,
  1236.                                             (TrackObjectRec*)ArrayGetElement(PlayTrackList,0),0,SamplingRate,
  1237.                                             EnvelopeRate,StereoPlayback,Double2LargeBCD(DefaultBeatsPerMinute),
  1238.                                             Double2LargeBCD(VolumeScaling),TimeInterpolation,
  1239.                                             WaveInterpolation,Double2LargeBCD(ScanningGap),NumberOfBits,
  1240.                                             ClipWarning && ((eOptionKey & CheckModifiers()) == 0));
  1241.                                     }
  1242.                                 DisposeArray(PlayTrackList);
  1243.                                 goto JumpBackIntoLoopPoint;
  1244.                         }
  1245.                 }
  1246.         }
  1247.  
  1248.         DisposeStringList(Window->TrackActivationList);
  1249.         DisposeSimpleButton(Window->SelectAllButton);
  1250.         DisposeSimpleButton(Window->SelectNoneButton);
  1251.         DisposeSimpleButton(Window->CancelButton);
  1252.         DisposeSimpleButton(Window->DontPlayButton);
  1253.         DisposeSimpleButton(Window->PlayAudioButton);
  1254.         DisposeSimpleButton(Window->PlayDiskButton);
  1255.         DisposeTextEdit(Window->SampleRateEdit);
  1256.         DisposeTextEdit(Window->EnvelopeRateEdit);
  1257.         DisposeTextEdit(Window->BeatsPerMinEdit);
  1258.         DisposeTextEdit(Window->VolumeEdit);
  1259.         DisposeTextEdit(Window->ScanningGapEdit);
  1260.         DisposeTextEdit(Window->DurationWidthEdit);
  1261.         DisposeRadioButton(Window->Bits8Button);
  1262.         DisposeRadioButton(Window->Bits16Button);
  1263.         DisposeRadioButton(Window->Bits24Button);
  1264.         DisposeRadioButton(Window->Bits32Button);
  1265.         DisposeRadioButton(Window->StereoButton);
  1266.         DisposeRadioButton(Window->MonoButton);
  1267.         DisposeCheckBox(Window->InterpTimeButton);
  1268.         DisposeCheckBox(Window->InterpWaveButton);
  1269.         DisposeCheckBox(Window->ClipWarnButton);
  1270.         KillWindow(Window->ScreenID);
  1271.         ReleasePtr((char*)Window);
  1272.         /* no return value */
  1273.     }
  1274.